package com.lsfb.duishangbaos.HomePage.Setting;

import android.content.Intent;
import android.net.Uri;
import android.view.View;

import com.lsfb.duishangbaos.Login.LoginActivity;
import com.lsfb.duishangbaos.Login.ShopEnter.GetPhoneBean;
import com.lsfb.duishangbaos.R;
import com.lsfb.duishangbaos.Utils.LittleUtils;
import com.lsfb.duishangbaos.Utils.URLString;
import com.zgscwjm.lsfbbasetemplate.Event.EventAnnotation;
import com.zgscwjm.lsfbbasetemplate.LsfbActivity;
import com.zgscwjm.lsfbbasetemplate.annotation.ContentView;
import com.zgscwjm.lsfbbasetemplate.annotation.OnClick;
import com.zgscwjm.lsfbbasetemplate.internet.BaseInternet;

import java.util.HashMap;

/**
 * Created by Administrator on 2017/5/9 0009.
 */
@ContentView(R.layout.aty_setting)
public class SettingActivity extends LsfbActivity {

    private String phone="";

    @Override
    public void initView() {
        LittleUtils.setsimpletitlebar(this, "设置");

    }

    @Override
    public void initEvent() {

    }

    /**
     * 点击事件
     *
     * @param view
     */
    @OnClick({R.id.aty_setting_pwd, R.id.aty_setting_kefu, R.id.aty_btn_exit})
    public void onClick(View view) {
        switch (view.getId()) {
            //密码管理
            case R.id.aty_setting_pwd:
                startActivity(new Intent(this, AmendPwdActivity.class));
                break;
            //联系客服
            case R.id.aty_setting_kefu:
                startActivity(new Intent(
                        "android.intent.action.CALL", Uri.parse("tel:"
                        + phone)));
                break;
            //退出
            case R.id.aty_btn_exit:
                LittleUtils.exit(this);
                startActivity(new Intent(this, LoginActivity.class));
                break;
        }
    }

    @Override
    public void initData() {
        getPhone();
    }

    public void getPhone() {
        HashMap<String, String> hashMap = new HashMap<String, String>();

        new BaseInternet().getData_Get(URLString.TEL, hashMap, GetPhoneBean.class, new GetPhoneEvent2<GetPhoneBean>(), true, false);
    }

    @EventAnnotation
    public void GetPhoneEvent2(GetPhoneEvent2<GetPhoneBean> event) {
        switch (event.getCode()) {
            case 200:
                phone=event.getData().getTel();
                break;
            default:
                break;
        }
    }

}
